<link rel="stylesheet" href="/Content/FileUpload/css/jquery.fileupload.css" />
<link href="/Content/css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="/Content/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
<script src="/Content/js/plugins/sweetalert/sweetalert.min.js"></script>

<div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>APP设置</h5>
                           
                        </div>
						
                        <div class="ibox-content">
                            <form  action="/index.php/Home/Index/appinfo" onsubmit="return dataupdate();" id="myform" method="post" class="form-horizontal"  enctype="multipart/form-data">
                             
							 	<div class="form-group"><label class="col-sm-2 control-label">通信服务器带端口</label>
                                    <div class="col-sm-10">
									<input type="text" name="socketurl"  class="form-control" value="{$info.socketurl}"></div>
                                </div>
							 <div class="form-group"><label class="col-sm-2 control-label">点播文字</label>
                                    <div class="col-sm-10">
									<input type="text" name="dianbotitle"  class="form-control" value="{$info.dianbotitle}"></div>
                                </div>
								
								
							<div class="form-group"><label class="col-sm-2 control-label">点播LOGO</label>
											  <div class="col-sm-10">
										<span class="btn btn-success fileinput-button">
											<i class="glyphicon glyphicon-plus"></i>
											<span>添加图片</span>
											
										  <input id="fileupload" type="file" name="imgFile" multiple>
											
										</span>
									
										<div id="showpic">
										  <if condition="($info.dianboimg neq '')"> 
										<img src="/{$info.dianboimg}"  width="100px" id="showimg"/> 
											<else /> 
												
											</if>
											<a class="delimg">删除图片</a>
										</div>
									</div>
                                </div>
								
								
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-2">
                                        <button class="btn btn-primary" type="submit" >保存</button>
                                    </div>
                                </div>
								
								<input type="hidden" name="dianboimg" id="imgurl" value="{$info.dianboimg}" />
                            </form>
                        </div>
                    </div>
                </div>

<script src="/Content/FileUpload/js/vendor/jquery.ui.widget.js"></script>
<script src="/Content/FileUpload/js/jquery.iframe-transport.js"></script>
<script src="/Content/FileUpload/js/jquery.fileupload.js"></script>
<script src="https://cdn.socket.io/socket.io-1.2.1.js"></script>
<script>
 $(function () {
 
 	initsocket();
                'use strict';
                var url = "/upload.php";
                $('#fileupload').fileupload({
                    autoUpload: true,//是否自动上传
                    url: url,
                    dataType: 'json',
                    done: function (e, data) {
                       
                        console.log(data.result);
                        if (data.result.error == 1) {
                            swal("上传出错了!", data.result.message, "success");
                        } else {
                            var pic = data.result.pic;
                            $("#showpic").html("<img src='/" + pic + "' width='100px'/>");
                            $("#imgurl").val(pic);


                        }
                    },
                    progressall: function (e, data) {
                        var progress = parseInt(data.loaded / data.total * 100, 10);
                        $('#progress .progress-bar').css(
                            'width',
                            progress + '%'
                        );
                    }
                }).prop('disabled', !$.support.fileInput)
                    .parent().addClass($.support.fileInput ? undefined : 'disabled');
					
		$(".delimg").click(function(){
			$("#imgurl").val("");
			$("#showimg").remove();
		});
					
});
function initsocket(){
	socket=io.connect('{$socket}');//与服务器进行连接		
}
function dataupdate(){
var appname=$("#appname").val();
var tqshow=$("#tqshow").val();
var imgurl=$("#imgurl").val();

	var json = {};
		json.type="updateinfo";
		json.content= imgurl;
		json.zuid= "";
		var str= JSON.stringify(json);
		console.log(str);
		socket.emit('broadcast',str);
		
	return true;
}
</script>
